<template>
  <tr>
    <td>
      <input @change="check" :checked="checked" type="checkbox" /> <span></span>
    </td>
    <td>{{ name }}</td>
    <td>{{ price }}</td>
    <td>
      <button @click="sub">-</button>
      &nbsp;{{ num }}&nbsp;
      <button @click="add">+</button>
    </td>
    <td>{{ num * price }}</td>
    <td><button @click="del">删除</button></td>
  </tr>
</template>

<script>
export default {
  props: ["name", "price", "num", "index", "checked"],

  methods: {
    add() {
      this.$emit("plus", this.index);
    },
    sub() {
      this.$emit("lose", this.index);
    },
    check() {
      this.$emit("check", this.index);
    },
    del() {
      this.$emit("delete", this.index);
    },
  },
};
</script>

<style scoped></style>
